﻿#
# Custom PowerShell object to represent a CSV data row.
# https://wdadsync.codeplex.com/
# 2014.08.07
#

#Region Custom PowerShell object to represent an Employee/AD account.
Function New-EmployeeObjectFromCSV {
	[cmdletbinding()]
    Param(
		[parameter(Mandatory=$true)]
		[ValidateNotNullOrEmpty()]
		[string] $Pref_First_Name,
		
		[parameter(Mandatory=$true)]
		[ValidateNotNullOrEmpty()]
		[string] $Pref_Last_Name,
		
		[parameter(Mandatory=$true)]
		[ValidateNotNullOrEmpty()]
		[string] $Full_Legal_Name,
		
		[parameter(Mandatory=$true)]
		[ValidateNotNullOrEmpty()]
		[string] $Job_Title,
		
		[parameter(Mandatory=$true)]
		[ValidateNotNullOrEmpty()]
		[string] $Worker_s_Manager,
		
		[parameter(Mandatory=$true)]
		[AllowEmptyString()]
		[string] $Email_Work,
		
		[parameter(Mandatory=$true)]
		[ValidateNotNullOrEmpty()]
		[string] $Primary_Work_Address,
		
		[parameter(Mandatory=$true)]
		[AllowEmptyString()]
		[string] $Work_Address_Formatted_Line_1,
		
		[parameter(Mandatory=$true)]
		[ValidateNotNullOrEmpty()]
		[string] $Work_Address_City,
		
		[parameter(Mandatory=$true)]
		[ValidateNotNullOrEmpty()]
		[string] $Work_Address_Postal_Code,
		
		[parameter(Mandatory=$true)]
		[AllowEmptyString()]
		[string] $Work_Address_State_Province,
		
		[parameter(Mandatory=$true)]
		[AllowEmptyString()]
		[string] $Phone_Number_Primary_with_Country_Code,
		
		[parameter(Mandatory=$true)]
		[AllowEmptyString()]
		[string] $Mobile_Phone_Number,
		
		[parameter(Mandatory=$true)]
		[ValidateNotNullOrEmpty()]
		[string] $location,
		
		[parameter(Mandatory=$true)]
		[ValidateNotNullOrEmpty()]
		[string] $Employee_ID,
		
		[parameter(Mandatory=$true)]
		[ValidateNotNullOrEmpty()]
		[string] $Manager_ID,
		
		[parameter(Mandatory=$true)]
		[AllowEmptyString()]
		[string] $Room
    )
    Process {
		$employeeObject = New-Object PSObject
		Add-Member -InputObject $employeeObject -MemberType NoteProperty `
			-Name "FirstName" -Value $Pref_First_Name
		Add-Member -InputObject $employeeObject -MemberType NoteProperty `
			-Name "LastName" -Value $Pref_Last_Name
		Add-Member -InputObject $employeeObject -MemberType NoteProperty `
			-Name "LegalName" -Value $Full_Legal_Name
		Add-Member -InputObject $employeeObject -MemberType NoteProperty `
			-Name "Title" -Value $Job_Title
		Add-Member -InputObject $employeeObject -MemberType NoteProperty `
			-Name "Manager" -Value $Worker_s_Manager
		Add-Member -InputObject $employeeObject -MemberType NoteProperty `
			-Name "Email" -Value $Email_Work
		Add-Member -InputObject $employeeObject -MemberType NoteProperty `
			-Name "Addr1" -Value $Primary_Work_Address
		Add-Member -InputObject $employeeObject -MemberType NoteProperty `
			-Name "Addr2" -Value $Work_Address_Formatted_Line_1
		Add-Member -InputObject $employeeObject -MemberType NoteProperty `
			-Name "City" -Value $Work_Address_City
		Add-Member -InputObject $employeeObject -MemberType NoteProperty `
			-Name "PostalCode" -Value $Work_Address_Postal_Code
		Add-Member -InputObject $employeeObject -MemberType NoteProperty `
			-Name "Province" -Value $Work_Address_State_Province
		Add-Member -InputObject $employeeObject -MemberType NoteProperty `
			-Name "Phone" -Value $Phone_Number_Primary_with_Country_Code
		Add-Member -InputObject $employeeObject -MemberType NoteProperty `
			-Name "Mobile" -Value $Mobile_Phone_Number
		Add-Member -InputObject $employeeObject -MemberType NoteProperty `
			-Name "Location" -Value $location
		Add-Member -InputObject $employeeObject -MemberType NoteProperty `
			-Name "EmployeeID" -Value $Employee_ID
		Add-Member -InputObject $employeeObject -MemberType NoteProperty `
			-Name "Manager_ID" -Value $Manager_ID
		Add-Member -InputObject $employeeObject -MemberType NoteProperty `
			-Name "OfficeNumber" -Value $Room
			
		return($employeeObject)
    }	
}